<?php

class Utility extends PrspLibrary{
	
	public function initial(){}
	
	public function getSelfPluginId(){
		$pluginId = str_replace(PLUGINS_PATH, '', __FILE__);
		return substr($pluginId,1,strpos($pluginId, '/', 2)-1);
	}
	
	/**
	 * Check email string format
	 *
	 * @param unknown_type $email
	 * @return unknown
	 */
	function checkEmailFormat($email){
    	if( eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email) )
       		return true;
    	else
        	return false;
	}

	/**
	 * Get browser name
	 *
	 * @return String browser name
	 */
	function getBrowser() {
		$browserVersion = array ('MSIE', 'Firefox', 'Opera', 'Safari', 'Netscape' );
		$i = 0;
		while ( $i < count ( $browserVersion ) ) {
			if (strstr ( $_SERVER ['HTTP_USER_AGENT'], $browserVersion [$i] )) {
				return $browserVersion [$i];
			}
			$i ++;
		}
		return 'unknow';
	}

	/**
	 * Get browser version
	 *
	 * @return String browser version
	 */
	function getBrowserVision() {
		$info = explode ( '/', $_SERVER ['HTTP_USER_AGENT'] );
		if (isset ( $info [1] )) {
			return chop ( $info [1] );
		}
	}

	/**
	 * Verify request
	 *
	 * @param array $colNames
	 * @return boolean
	 */
	function checkValues(array $colNames){
    	foreach ($colNames as &$inp){
  	    	if( !array_key_exists( $inp,$_REQUEST ) || chop($_REQUEST[$inp])==='' )  return false;
    	}
    	return true;
	}

	/**
	 * Remove HTML tags and special symbols
	 *
	 * @param String $str
	 * @return String
	 */
	public function removeHtmlTagAndSymbols( $str ){
    	$str = strip_tags(str_replace(' ','',$str ));
    	$str = eregi_replace('[^[:alnum:]+]','', $str);
		return($str);
	}
	
}


?>